using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 教练、私教管理
    /// </summary>
    public class CoacherController : ApiController
    {
        private readonly ICoacherService _coacherService;

        /// <summary>
        /// 教练管理
        /// </summary>
        public CoacherController(
            ICoacherService coacherService
            )
        {
            _coacherService = coacherService;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="id">教练ID</param>
        [HttpGet("get")]
        public async Task<UnaryResult<CoacherDto>> GetAsync(Guid id)
        {
            var result = await _coacherService.GetAsync(id);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 查询
        /// </summary>
        [HttpPost("query")]
        public async Task<UnaryResult<CoacherDto>> QueryAsync()
        {
            var result = await _coacherService.QueryAsync();
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 分页请求
        /// </summary>
        [HttpPost("pagelist")]
        public async Task<UnaryResult<PageResult<CoacherDto>>> PageListAsync(CoacherPageRequestDto request)
        {
            var result = await _coacherService.PageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost("add")]
        public async Task<UnaryResult> AddAsync(CoacherAddDto model)
        {
            var result = await _coacherService.AddAsync(model);
            return result;
        }

        /// <summary>
        /// 修改图片、介绍
        /// </summary>
        [HttpPost("update_simple")]
        public async Task<UnaryResult> UpdateSimpleAsync(CoacherSimpleUpdateDto model)
        {
            var result = await _coacherService.UpdateSimpleAsync(model);
            return result;
        }

        /// <summary>
        /// 教练评星
        /// </summary>
        [HttpPost("add_star")]
        public async Task<UnaryResult> AddStarAsync(CoacherStarAddDto request)
        {
            var result = await _coacherService.AddStarAsync(request);
            return result;
        }

        /// <summary>
        /// 添加场馆
        /// </summary>
        [HttpPost("add_venue")]
        public async Task<UnaryResult> AddVenueAsync(CoacherVenueAddDto request)
        {
            var result = await _coacherService.AddVenueAsync(request);
            return result;
        }

        /// <summary>
        /// 更新教练场馆
        /// </summary>
        [HttpPost("update_venue")]
        public async Task<UnaryResult> UpdateVenueAsync(CoacherVenueUpdateDto request)
        {
            var result = await _coacherService.UpdateVenueAsync(request);
            return result;
        }

        /// <summary>
        /// 删除场馆
        /// </summary>
        [HttpGet("delete_venue")]
        public async Task<UnaryResult> DeleteVenueAsync([Required] Guid venueId)
        {
            var result = await _coacherService.DeleteVenueAsync(venueId);
            return result;
        }

        /// <summary>
        /// 添加学员
        /// </summary>
        [HttpPost("add_student")]
        public async Task<UnaryResult> AddStudentAsync(CoacherStudentAddDto request)
        {
            var result = await _coacherService.AddStudentAsync(request);
            return result;
        }

        /// <summary>
        /// 私教学生删除
        /// </summary>
        [HttpPost("delete_student")]
        public async Task<UnaryResult> DeleteStudentAsync(CoacherStudentDelDto request)
        {
            var result = await _coacherService.DeleteStudentAsync(request);
            return result;
        }

        /// <summary>
        /// 私教学生更新
        /// </summary>
        [HttpPost("update_student")]
        public async Task<UnaryResult> UpdateStudentAsync(CoacherStudentUpdateDto request)
        {
            var result = await _coacherService.UpdateStudentAsync(request);
            return result;
        }

        /// <summary>
        /// 获取私教学生分页列表
        /// </summary>
        [HttpPost("pagelist_personal_student")]
        public async Task<UnaryResult<PageResult<CoacherStudentDto>>> GetCoacherStudentPageList(CoacherStudentPageRequestDto request)
        {
            var result = await _coacherService.GetCoacherStudentPageList(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 获取私教学生记录列表
        /// </summary>
        [HttpPost("pagelist_personal_student_record")]
        public async Task<UnaryResult<PageResult<CoacherStudentRecordDto>>> GetCoacherStudentRecordPageList(CoacherStudentRecordPageRequestDto request)
        {
            var result = await _coacherService.GetCoacherStudentRecordPageList(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 私教学生点名
        /// </summary>
        [HttpPost("call_student")]
        public async Task<UnaryResult> CallStudentAsync(CoacherStudentRequestDto request)
        {
            var result = await _coacherService.CallStudentAsync(request);
            return result;
        }

        /// <summary>
        /// 私教预约列表
        /// </summary>
        /// <param name="date">日期</param>
        [HttpGet("list_booking")]
        public async Task<UnaryResult<List<CoacherBookGroupDto>>> GetCoacherBookingListAsync([Required] DateTimeOffset date)
        {
            var result = await _coacherService.GetCoacherBookingListAsync(date);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 我的私教预约列表
        /// </summary>
        [HttpPost("list_booking_self")]
        public async Task<UnaryResult<List<CoacherBookDto>>> GetMyCoacherBookingListAsync(MyCoacherBookRequestDto request)
        {
            var result = await _coacherService.GetMyCoacherBookingListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 私教预约详情
        /// </summary>
        /// <param name="businessId">业务ID</param>
        [HttpGet("get_booking")]
        public async Task<UnaryResult<CoacherBookGroupDto>> GetCoacherBookingAsync([Required] Guid businessId)
        {
            var result = await _coacherService.GetCoacherBookingAsync(businessId);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 私教预约增加
        /// </summary>
        [HttpPost("add_booking")]
        public async Task<UnaryResult> AddCoacherBookingAsync(CoacherBookAddDto request)
        {
            var result = await _coacherService.AddCoacherBookingAsync(request);
            return result;
        }

        /// <summary>
        /// 私教预约更新
        /// </summary>
        [HttpPost("update_booking")]
        public async Task<UnaryResult> UpdateCoacherBookingAsync(CoacherBookUpdateDto request)
        {
            var result = await _coacherService.UpdateCoacherBookingAsync(request);
            return result;
        }

        /// <summary>
        /// 私教预约状态更新
        /// </summary>
        [HttpPost("update_booking_state")]
        public async Task<UnaryResult> UpdateCoacherBookingStateAsync(CoacherBookStateUpdateDto request)
        {
            var result = await _coacherService.UpdateCoacherBookingStateAsync(request);
            return result;
        }
    }
}
